﻿/// <Summary> 
/// $Author: Nikhil Chinchwade 
/// This file contains logic for connecting to an Azure deployment

/// $Creation Date : 
/// </summary>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MindTree.PerfWorkbench.Azure.Monitor.Core;

namespace MindTree.PerfWorkbench.Azure.Monitor
{
    /// <summary>
    /// Interaction logic for AzureConnectDialog.xaml
    /// </summary>
    public partial class AzureConnectDialog : Window
    {
        public static Boolean IsOK = false;
        
        public AzureConnectDialog()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Connect to an Azure deoployment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            IsOK = true;
            
            if (String.IsNullOrEmpty(txtAccountName.Text) || String.IsNullOrEmpty(txtAccountKey.Text) || String.IsNullOrEmpty(txtDeploymentID.Text))
            {
                MessageBox.Show("Specify All Required Fields");
                return;
            }
            AzureMonInstanceContext.AzureApp.AppConnectionConfig.AccountName = txtAccountName.Text.Trim();
            AzureMonInstanceContext.AzureApp.AppConnectionConfig.AccountKey = txtAccountKey.Text.Trim();
            AzureMonInstanceContext.AzureApp.AppConnectionConfig.AppDeploymentId = txtDeploymentID.Text.Trim();
            Close();
        }

        /// <summary>
        /// Cancel the connect operation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            IsOK = false;
            Close();
        }


    }
}
